extends layout

block content
	div(ng-app="app-cart")
		div(ng-controller="cartsController")
			h1 Carrito de Compras
			input(type="text", placeholder="Buscar", class="form-control", ng-model="busqueda")
			table(class="table")
				thead
					tr
						th Seleccionar
						th Nombre del Producto
						th Cantidad
						th Precio
						th Importe
				tbody
					tr(ng-repeat="elemento in elementos | filter:busqueda")
						td 
							input(type="checkbox", ng-model="elemento.seleccionar")
						td {{elemento.producto.nombre}}
						td 
							input(type="number", ng-model="elemento.cantidad", ng-change="calcularTotal()" )
						td {{elemento.producto.precio}}
						td {{elemento.cantidad * elemento.producto.precio}}
					tr
						td &nbsp;
						td &nbsp;
						td &nbsp;
						td 
							strong TOTAL:
						td 
							strong {{total}}

			div(class="panel-group", id="accordionTotal")
				div(class="panel panel-default")
					div(class="panel-heading")
						h4(class="panel-title")
							a(class="accordion-toggle", data-toggle="collapse", data-parent="#accordionTotal", href="#collapseTwo") Total: {{total + (total * 0.16)}}
					div(id="collapseTwo", class="panel-collapse collapse in")
						div(class="panel-body")
							label SubTotal: {{total}}
							br
							label I.V.A: {{total* 0.16}}
							br
							strong Total: {{total + (total * 0.16)}}
			br
			div(class="panel-group", id="accordion")
				div(class="panel panel-default")
					div(class="panel-heading")
						h4(class="panel-title")
							a(class="accordion-toggle", data-toggle="collapse", data-parent="#accordion", href="#collapseOne") Agregar
					div(id="collapseOne", class="panel-collapse collapse in")
						div(class="panel-body")
							label Producto&nbsp;
							select(ng-model="newElement.producto", class="form-control", ng-options = "producto.nombre for producto in productos")
							label &nbsp;Precio&nbsp;
							input(ng-model="newElement.producto.precio", class="form-control", type="number" disabled="disabled")
							label &nbsp;Cantidad&nbsp;
							input(type="number", class="form-control", ng-model="newElement.cantidad")
							br
							button(class="btn btn-success btn-sm" ng-click="agregar()") Agregar
